﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Automted_Bank_teller
{
    public partial class ShuffleForm : Form
    {
        public ShuffleForm()
        {
            InitializeComponent();
        }

        private void ShuffleForm_Load(object sender, EventArgs e)
        {
            
        }


        private void BTN_clientFun_shuffle_Submit_Click(object sender, EventArgs e)
        {
            try
            {

                if (txtbox_clientFun_shuffle_clientID.Text.Length > 0 && txtbox_clientFun_shuffle_MoneyToBeShuffled.Text.Length > 0)
                {
                    shuflle_logicc update = new shuflle_logicc();
                    update.update_shuffle(float.Parse(txtbox_clientFun_shuffle_MoneyToBeShuffled.Text));
                    
               
                Shuffle_Process Select_TwoAcount_balace = new Shuffle_Process();
                Select_TwoAcount_balace.Database_ConnectString();
                Select_TwoAcount_balace.Open_Database();
                Select_TwoAcount_balace.selectData();
                Select_TwoAcount_balace.GetCurrentBalance();
                Select_TwoAcount_balace.Close_Database();
                shuflle_logicc fire1 = new shuflle_logicc();
                fire1.moneyafftershuffle();
                fire1.GetClient_Id(txtbox_clientFun_shuffle_clientID.Text);

                Select_TwoAcount_balace.Open_Database();
                Select_TwoAcount_balace.select_sent_to();

                Select_TwoAcount_balace.GetCurrentBalance_sent_to_client();
                Select_TwoAcount_balace.Close_Database();
                shuflle_logicc fire = new shuflle_logicc();
                fire.moneyafftershuffle_SentToClient();
                fire.GetClient_Id(txtbox_clientFun_shuffle_clientID.Text);
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                
                
                Select_TwoAcount_balace.Open_Database();
                Select_TwoAcount_balace.Upade_mainClient_Money();
                Select_TwoAcount_balace.ExecuteQuery();
                Select_TwoAcount_balace.Close_Database();
                    /***************************/
               Select_TwoAcount_balace.Open_Database();
               Select_TwoAcount_balace.Upadte_secondClientAcount();
                Select_TwoAcount_balace.ExecuteQuery();
                Select_TwoAcount_balace.Close_Database();
                    MessageBox.Show("Successful Money Transfer");
                }
                else
                {
                    MessageBox.Show("Empty Fields Not Allowd");
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }


        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }    
                      
    }
}
